]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellNetworkAgent: don't access request fields if the operation is cancelled
authorGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 13 Feb 2012 14:54:46 +0000 (15:54 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 14 Feb 2012 18:16:50 +0000 (19:16 +0100)
When the operation is cancelled by NetworkManager, the request is
cancelled immediately. Later when gnome-keyring invokes the callback
notifying the error we must therefore not access its memory.
Previously the callback would mistakenly treat "cancelled" (which
indicates a programmatic cancel) as "denied" (which means the user
clicked "Cancel" on the keyring prompt)

https://bugzilla.gnome.org/show_bug.cgi?id=658484

src/shell-network-agent.c

index b24999b7502722fd279df0340f3b6f35fe24db7c..964023694d21669bd28293596f1d899d51a9da27 100644 (file)
@@ -229,22 +229,29 @@ get_secrets_keyring_cb (GnomeKeyringResult  result,
                        GList              *list,
                        gpointer            user_data)
 {
-  ShellAgentRequest *closure = user_data;
-  ShellNetworkAgent *self = closure->self;
-  ShellNetworkAgentPrivate *priv = self->priv;
+  ShellAgentRequest *closure;
+  ShellNetworkAgent *self;
+  ShellNetworkAgentPrivate *priv;
   GError *error = NULL;
   gint n_found = 0;
   GList *iter;
   GHashTable *outer;
 
+  if (result == GNOME_KEYRING_RESULT_CANCELLED)
+    return;
+
+  closure = user_data;
+  self = closure->self;
+  priv  = self->priv;
+
   closure->keyring_op = NULL;
 
-  if (result == GNOME_KEYRING_RESULT_CANCELLED)
+  if (result == GNOME_KEYRING_RESULT_DENIED)
     {
       g_set_error (&error,
                   NM_SECRET_AGENT_ERROR,
                   NM_SECRET_AGENT_ERROR_USER_CANCELED,
-                  "The secret request was cancelled by the user");
+                  "Access to the secret storage was denied by the user");
 
       closure->callback (NM_SECRET_AGENT (closure->self), closure->connection, NULL, error, closure->callback_data);